package design.single;

public class Hungry {
    //饿汉式单例
    //一上来就全部进行加载，构造器私有

    //饿汉式像下面这种情况会很浪费内存，一上来全部进行内存申请，但并没有进行存放
    private byte[] data1 = new byte[1024*1024];
    private byte[] data2 = new byte[1024*1024];
    private byte[] data3 = new byte[1024*1024];
    private byte[] data4 = new byte[1024*1024];

    //私有无参构造器
    private Hungry(){

    }
    private final static Hungry HUNGRY = new Hungry();

    public static Hungry getInstance(){
        return HUNGRY;
    }
}
